package com.acwing.partition1;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

public class AC12背包问题求具体方案 {
    
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = reader.readLine().split(" ");
        int n = Integer.parseInt(s[0]), m = Integer.parseInt(s[1]);
        int[][] nums = new int[n][2];
        for (int i = 0; i < n; i++) {
            s = reader.readLine().split(" ");
            nums[i][0] = Integer.parseInt(s[0]);
            nums[i][1] = Integer.parseInt(s[1]);
        }
        int[] ans = dynamicProgramming(nums, m);
        for (int i = 0; i < ans.length; i++) writer.write(ans[i] + " ");
        writer.flush();
    }

    private static int[] dynamicProgramming(int[][] nums, int capacity) {
        int[][] dp = new int[nums.length + 1][capacity + 1];
        //为了保证字典序，物品需要反向遍历，因为是01背包，体积也要和物品遍历方向相反
        for (int i = nums.length - 1; i >= 0; i--) {
            int v = nums[i][0], w = nums[i][1];
            for (int j = 0; j <= capacity; j++) {
                if (j - v < 0) {
                    dp[i][j] = dp[i + 1][j];
                    continue;
                }
                dp[i][j] = Math.max(dp[i + 1][j], dp[i + 1][j - v] + w);
            }
        }
        List<Integer> answer = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            int v = nums[i][0], w = nums[i][1];
            if (capacity >= v && dp[i][capacity] == dp[i + 1][capacity - v] + w) {
                answer.add(i + 1);
                capacity -= v;
            }
        }
        return answer.stream().mapToInt(val -> val).toArray();
    }
}
